#ifndef EXAMPLES_LOCAL_OPTIONS_H
#define EXAMPLES_LOCAL_OPTIONS_H

#include <nsi/walking/config.h>
#include <stdint.h>
#include <string>
#include <stdexcept>
#include <getopt.h>
#include <nsi/thinklink/stl.h>

namespace examples {

struct local_options
{
  // Device types
  struct device_types
  {
    enum value
    {
      serial,
      socket,
    };
  };

  // Types
  typedef enum device_types::value device_type;
  typedef ::nsi::thinklink::stl::string string;
  typedef ::nsi::thinklink::stl::runtime_error runtime_error;

  // Option defaults
  struct defaults
  {
    static const device_type device;

    static const char* serial_path;

    static const char* socket_address;
    static const uint16_t socket_port;

    static const int time;
    static const bool single;

    static const bool remote;
  };

  // Construct options
  explicit local_options(int argc = 0, char* const argv[] = 0);

  // Parse command line arguments
  bool parse(int argc, char* const argv[]);

  bool parse();
  
  // Print usage
  void usage();

  // Accessors
  
  // Returns if the device type is serial
  bool serial() const
  {
    return device == device_types::serial;
  }

  // Returns if the device type is socket
  bool socket() const
  {
    return device == device_types::socket;
  }
  
  static const char* short_options;
  static const struct option long_options[];

  // Argument number
  int argc;
  // Argument vector
  char* const* argv;

  // Device
  device_type device;

  // Serial
  string serial_path;
  
  // Socket
  string socket_address;
  uint16_t socket_port;

  // Time
  int time;
  // Single actuator
  bool single;
  // Use remote robot
  bool remote;
  bool keyboard;
};



} // namespace examples

#endif // !EXAMPLES_LOCAL_OPTIONS_H
